import numpy as np
def tri_equations(mat):
    col=len(mat)
    mat_coeff=mat[:,0:col]
    d=np.linalg.det(mat_coeff)
    if d==0:
        print("方程组没有唯一解")
        x=np.nan
    else:
        x=[]
        for k in range(col):
            m=mat_coeff.copy()
            m[:,k]=-mat[:,col]
            x.append(np.linalg.det(m)/d)
    return x


def cross_line(matrix):
    cross_point=[np.nan,np.nan]
    if np.linalg.det(matrix[:,0:2])==0:
        if np.linalg.det(matrix[:,1:3])==0:
            relation='两直线重合'
        else:
            relation="两直线平行"
    else:
        relation='两直线相交'
        cross_point=tri_equations(matrix)
    return relation,cross_point

A=np.array([[1,3,5],[8,3,9]])
use=cross_line(A)
print('两直线的位置关系为：{}'.format(use[0]))
print("------------")
print('两直线的交点坐标为：{}'.format(use[1]))